home *** CD-ROM | disk | FTP | other *** search
- /*
- * Title:
- * raster.c
- *
- * Authors:
- * Michael P. Schenck
- *
- * Purpose:
- * This module handles the output of the raster list constructed in
- * the viewing and perspective transformation (viewperstrans.c) module.
- * The scanconvert routine moves through the raster list and draws all
- * the polygons described. It uses the linemap for each object
- * (see database.c) to determine shared edges and not draw those
- * lines.
- *
- * Copyright Info:
- * Copyright (C) 1993, 1994 -- by Michael P. Schenck,
- * (mps4466@ultb.isc.rit.edu)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * For a copy of the GNU General Public License
- * write to the Free Software Foundation, 675 Mass Ave,
- * Cambridge, MA 02139, USA.
- *
- */
-
- #include <stdlib.h>
- #include <math.h>
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include "/include/errors.h"
- #include "/include/display.h"
- #include "/include/viewperstrans.h"
- #include "/include/matrix.h"
- #include "/include/database.h"
- #include "/include/raster.h"
-
- extern struct Object *objects[MAXNUMOBJECTS];
- extern ULONG objectviewlist[MAXPOLYINVIEW],
- polyviewlist[MAXPOLYINVIEW],
- viewlistindex;
- extern UWORD height;
-
- /* Scan convert (wireframe) all polys in the viewlist. */
-
- void scanconvert()
- {
-
- register WORD x0,y0,x1,y1,x2,y2;
- register ULONG i,j,offset,curpoly,curvert;
- WORD x,y;
- ULONG *polygons,curobject=NOOBJECT;
- FLOAT *transvert;
- UBYTE *edgeshare;
-
- for(i=0;i<viewlistindex;i++) {
-
- if(curobject != objectviewlist[i]) {
- curobject = objectviewlist[i];
- polygons = objects[curobject]->polygons;
- transvert = objects[curobject]->transvert;
- edgeshare = objects[curobject]->edgeshare;
- }
-
- curpoly = polyviewlist[i]*MAXPOLYVERT;
- curvert = *(polygons+curpoly);
- x = (WORD)*(transvert+curvert*4);
- y = height - (WORD)*(transvert+curvert*4+1);
- x2 = x;
- y2 = y;
-
- for(j=1;j<(MAXPOLYVERT-1);j++) {
- offset = j;
- if((curvert = *(polygons+curpoly+j))==NOVERT) {
- j=MAXPOLYVERT-1;
- x1 = x;
- y1 = y;
- }
- else {
- x1 = (WORD)*(transvert+curvert*4);
- y1 = height - (WORD)*(transvert+curvert*4+1);
- }
-
- x0 = x2;
- y0 = y2;
- x2 = x1;
- y2 = y1;
-
- /* Draw line if not already drawn. */
-
- if(*(edgeshare+curpoly+offset-1))
- line(x0,y0,x1,y1);
- }
- }
- }
-